/* 计算1000! */

#include <stdio.h>

#define N     1000000

int main(int argc, char const* argv[])
{
    int r[1000] = {1}; 
    int i, j, c, b, max;
    
    /*
     * c: 进位, b: 当前位计算结果， max: 最大位数, N: N进制
     */
    for (i = 1, max = 0; i <= 1000; i++) {
        for (j = 0, c = 0; j <= max; j++)
        {
            b = r[j]*i+c;
            r[j] = b%N;
            c = b/N;
        }
        if (c > 0)
            r[++max] = c;
    }

    printf("%d", r[max]);
    for (i = max-1; i >= 0; i --)
        printf("%06d", r[i]);

    return 0;
}
